<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta charset="UTF-8">
		<title>确认订单</title>
		<!-- amazeui -->
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/ui/css/amazeui.min.css" />
		<!-- lib -->
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/lib/swiper/css/swiper.min.css" />
		<!-- app -->
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/app/css/ui.css" />
		<%-- <link rel="stylesheet" href="${BASE_PATH}/static/app/css/base.css" /> --%>
		<link rel="stylesheet" href="${BASE_PATH}/static/app/css/header.css" />
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/app/css/order.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/app/css/m_cart.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/app/css/public.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/app/css/confirmOrder.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/lib/myAlert/myAlert.css" />
	   <style type="text/css">
			.top{
				border-bottom: 1px solid #DDDDDD;
			}
			.bottom i{
				font-size: 14px;
			}
			.more{
				display: none;
			}
			.show{
				display: inline-block;
			}
			.item{
				position: absolute;
				right: 10px;
				top: 100px;
			}
			.line{
				display: inline-block;
				width: 110%;
				height: 1px;
				background: #808080;
				position: absolute;
				left: 0;
				top: 50%;
				margin-top: -1px;
			}
			.kehuo {
				width: 100%;
				height: 40px;
				background: #FFFFFF;
				line-height: 40px;
				color: #c0c0c0;
			}
			.one {
				float: left;
				margin-left: 1em;
				font-size: 12px;
			}
			#num{
				width: 28px;
				height: 24px;
				text-align:center;
				font-size: 18px;
				background-color:  #f7f7f7;
				vertical-align: middle;
			}
			.goods_list{
			   padding-left: 10px;
			}
			.fff{
				padding-top: 40px;
			}
			.logo_text {
			    height: 40px;
			    line-height: 40px;
			    display: inline-block;
			    color: #595b60;
			    font-size: 14px;
			    margin-left: 6px;
				float: left;
			}
			 input{border:none;} 
			.goods_header{
				width: calc(100% - 10px);
				height: 30px;
			    margin-left: 10px;
			}
			.header_logo{
				width: 20px;
				height: 20px;
				margin-left: 4px;
				margin-top: 5px;
				float: left;
			}
			.header_logos{
				width: 20px;
				height: 20px;
			    margin-top: -5px;
			}
			.text_box {
			    height: 30px;
			    /* width: 100%; */
			    margin-left: 31px;
			    /* border-bottom: 1px solid #DDDDDD; */
			    line-height: 30px;
			    font-size: 12px;
			}
			.hed_ltext {
			    /* margin-right: 6px; */
			    line-height: 24px;
			}
			.tel_s{
				font-size: 12px;
				color: #e0e0e1;
				line-height: 12px;
				width: 100%;
			}
			.tel_xs{
				height: 35px;
   				 width: 50%;
   				border: 1px solid #bae5f0;
   				display: inline-block;
   				float: right;
   				margin-right: 25%;
   				 line-height:35px;
   				 text-align: center;
   				 border-radius: 35px;
   				 color: #bae5f0;
   				 font-size: 16px;
			}
			.tel_span{
				width: 100%;
			}
				.content{
				margin-bottom: 56px;
			}
			.telxs {
				width: 100%;
				height: 50px;
				box-sizing: border-box;
				padding: 15px 15px;
				background-color: white;
			}
			.bot{
				width: 100%;
				background: #FFFFFF;
				position: fixed;
				bottom: 0;
				display: none;
				height:220px; 
				overflow:auto;
			}
			a:hover, a:visited, a:link, a:active {
				color: #fff;
			}
			.shop{
				width: calc(100% - 20px);
				margin-left: 10px;
				height: 80px;
				line-height: 80px;
				border-bottom:1px solid #EDEDED ; 
				background: #fafafa;
				border-radius: 10px;
				margin-bottom: 5px;
			}
			.shop span{
				display:block;
				color: #5C5C67;
			}
			.tit{
				float: left;
				width: calc(100% - 55px);
				line-height: 40px;
				font-size: 16px;
				margin-left: 10px;
			}
			.nei{
				float: left;
				width: calc(100% - 55px);
				line-height: 20px;
				font-size: 12px;
				margin-left: 10px;
			}
			.dianhua{
				line-height: 45px;
				float: right;
				margin-top: -28px;
				width: 45px;
				height: 45px;
				text-align: center;
				/* border-left:1px solid #EDEDED ; */
				
			}
			.shop i{
				display: inline-block;
				width: 40px;
				height: 40px;
				margin-left: 5px;
				border-radius:40px;
				background: url(/static/app/img/dianhua.png) no-repeat 5px 3px;
				background-size:85% ;
			}
			
			.stio{
				width: calc(100% - 10px);
				margin-left: 15px;
				height: 30px;
				line-height: 30px;
				color: #a0a0a7;
			}
			.stios{
				width: calc(100% - 10px);
				margin-left: 15px;
				height: 30px;
				line-height: 30px;
				color: #a0a0a7;
				margin-top: 30px;
			}
	</style>
	</head>
	<body>
		<div class="content">
			<header>
				<div class="header">
					<span class="back" onclick="javascript:history.go(-1);"></span>
					<a href="${BASE_PATH}/index"><span class="logo_pic"></span></a>
					<span class="logo_text">OK 妈咪</span>
				</div>
			</header>
			<div class="fff">
				<div class="goods_header">
					<img class="header_logo" src="${BASE_PATH}/static/app/img/dianpu.png"/>
					<div class="text_box">
						<span class="hed_ltext" id="xdstore">${title }</span>
						<img class="header_logos" src="${BASE_PATH}/static/app/img/jiantou.png"/>
					</div>
				</div>
				<ul class="goods_list">
					<li class="goods-detail">
						<img class="goods_img" src="${FTP_PATH}${goods.thumb}" />
						<span class="goods_name">${goods.name } </span>
						<span class="goods-specTitle">${specs.specTitle}</span>
						<span class="goods_price" >						  
						<!-- 多种支付方式 -->						    
						   ¥<fmt:formatNumber type="number" value="${marketPrice}" pattern="0.00" maxFractionDigits="2"/><i class="line"></i>      
						</span>
						<span class="goods_weight" >						
						<!-- 选择的支付方式 -->
						<!-- 积分支付 -->
						     <c:if test="${payType==1}">
						       		<c:if test="${specs.integral>0 }">
										<span id="sppoint"><fmt:formatNumber type="number" value="${specs.integral }" pattern="0" maxFractionDigits="0"/> </span> 
			                        </c:if> 
			                        <c:if test="${specs.integral==-1 }">
										<span id="sppoint"><fmt:formatNumber type="number" value="0" pattern="0" maxFractionDigits="0"/> </span> 
			                        </c:if>   
							    <c:if test="${specs.integralType==1 }">商品积分 <b pointType="1"></b> </c:if><c:if test="${specs.integralType==2 }">健康积分 <b pointType="2"></b> </c:if><c:if test="${specs.integralType==3 }">教育积分 <b pointType="3"></b> </c:if>							    
							</c:if>
						<!-- 货币支付 -->	
							<c:if test="${payType==2}">	
									
										<span id="sppoint"><fmt:formatNumber type="number" value="${specs.currency }" pattern="0.00" maxFractionDigits="2"/> </span> 
			                       								     					      							    							     
							</c:if>
						<!-- 积分+货币支付 -->	
							<c:if test="${payType==3}">
							      <span id="sppoint"><fmt:formatNumber type="number" value="${specs.integCur_i }" pattern="0" maxFractionDigits="0"/></span> 
								  <c:if test="${specs.integCur_iType==1 }">商品积分  <b pointType="1"></b></c:if><c:if test="${specs.integCur_iType==2 }">健康积分 <b pointType="2"></b> </c:if><c:if test="${specs.integCur_iType==3 }">教育积分  <b pointType="3"></b></c:if>
								  +  ¥<span id="jine"><fmt:formatNumber type="number" value="${specs.integCur_c }" pattern="0.00" maxFractionDigits="2"/></span>
		
							</c:if> 					
						</span>
						<span class="item am-fr">
						        <span class="app-num am-fl counter">
								<span style="position: absolute;top: -18px;right: 26px;">×</span><input id="num" name="num" type="text" size="1" disabled="disabled"  value="${payNum}" style="margin-top: -44px;" />								
								</span>	
						<%-- 	<c:choose>							
								<c:when test="${payNum>0}">								
									<span class="app-num am-fl counter">								
									  <input id="num" name="num" type="text" size="1" disabled="disabled" value="× ${payNum}" />								
									</span>	
								</c:when>		
								<c:otherwise>
									<a class="app-btn app-btn-minus am-fl" href="javascript:doReduce();"><i class="am-icon-minus"></i></a>
									<span class="app-num am-fl counter">
									
									<input id="num" name="num" type="text" size="1" value="1" onchange="changenum();"/>
									
									</span>
									
									<a class="app-btn app-btn-plus am-fl" href="javascript:doAdd();"><i class="am-icon-plus"></i></a>
		                         </c:otherwise>
						   	</c:choose>
							
							<c:if test="${payNum==0}">
													</c:if> --%>
							<div class="am-cf"></div>
						</span>
					</li>
				</ul>
			</div>
	
				<div class="kehuo">
					<span class="one">可获得:</span>
					<!-- 积分支付 -->
					<c:if test="${payType==1}">
					    <span class="one" id="cartT"><span id="point3"><fmt:formatNumber type="number" value="0" pattern="0" maxFractionDigits="0"/></span>商品积分</span>
	                    <span class="one" id="cartT"><span id="point2"><fmt:formatNumber type="number" value="0" pattern="0" maxFractionDigits="0"/></span>健康积分</span>
					    <span class="one" id="cartT"><span id="point1"><fmt:formatNumber type="number" value="0" pattern="0" maxFractionDigits="0"/></span>教育积分</span> 
					</c:if>
					<!-- 货币支付 -->
					<c:if test="${payType==2}">					   
							<span class="one" id="cartT"><span id="point3"><fmt:formatNumber type="number" value="${specs.currency * payNum * sppoint }" pattern="0" maxFractionDigits="0"/></span>商品积分</span>
		                    <span class="one" id="cartT"><span id="point2"><fmt:formatNumber type="number" value="${specs.currency * payNum * jkpoint}" pattern="0" maxFractionDigits="0"/></span>健康积分</span>
						    <span class="one" id="cartT"><span id="point1"><fmt:formatNumber type="number" value="${specs.currency * payNum * jypoint }" pattern="0" maxFractionDigits="0"/></span>教育积分</span>    
					</c:if>
					<!-- 积分+货币支付 -->
					<c:if test="${payType==3}">
					    <span class="one" id="cartT"><span id="point3"><fmt:formatNumber type="number" value="${specs.integCur_c * payNum * sppoint }" pattern="0" maxFractionDigits="0"/></span>商品积分</span>
	                    <span class="one" id="cartT"><span id="point2"><fmt:formatNumber type="number" value="${specs.integCur_c * payNum * jkpoint}" pattern="0" maxFractionDigits="0"/></span>健康积分</span>
					    <span class="one" id="cartT"><span id="point1"><fmt:formatNumber type="number" value="${specs.integCur_c * payNum * jypoint }" pattern="0" maxFractionDigits="0"/></span>教育积分</span> 
					</c:if>
<%-- 				<span class="one" id="cartT"><span id="point2"><fmt:formatNumber type="number" value="${goods.sellPrice * jkpoint}" pattern="0" maxFractionDigits="0"/></span>健康积分</span>
					<span class="one" id="cartT"><span id="point1"><fmt:formatNumber type="number" value="${goods.sellPrice * jypoint }" pattern="0" maxFractionDigits="0"/></span>教育积分</span> --%>
				</div>
		
			<div class="total">
				<span class="total_text">总计 ：</span>
				<span class="total_num" id="cartTotal"> 

				     <c:if test="${payType==1}">
				    		<c:if test="${specs.integral>0 }">
								 <span id="sppoint2"><fmt:formatNumber type="number" value="${specs.integral * payNum}" pattern="0" maxFractionDigits="0"/> </span>  							    
	                        </c:if> 
	                        <c:if test="${specs.integral==-1 }">
								<span id="sppoint2"><fmt:formatNumber type="number" value="${0 * payNum}" pattern="0" maxFractionDigits="0"/> </span>  							     
	                        </c:if>	
						    <c:if test="${specs.integralType==1 }"><span integralType="1" id="integralType">商品积分</span> </c:if><c:if test="${specs.integralType==2 }"><span integralType="2" id="integralType">健康积分</span> </c:if><c:if test="${specs.integralType==3 }"><span integralType="3" id="integralType">教育积分</span> </c:if>
							<span id="jine2" style="display: none"><fmt:formatNumber type="number" value="0" pattern="0.00" maxFractionDigits="2"/></span>
					</c:if>
					<c:if test="${payType==2}">
					      <span id="sppoint2" style="display: none" ><fmt:formatNumber type="number" value="0" pattern="0" maxFractionDigits="0"/></span> 												      		 
					     		¥<span id="jine2"><fmt:formatNumber type="number" value=" ${specs.currency * payNum}" pattern="0.00" maxFractionDigits="2"/> </span>								                             			             		     
					</c:if>
					<c:if test="${payType==3}">
					      <span id="sppoint2"><fmt:formatNumber type="number" value="${specs.integCur_i * payNum}" pattern="0" maxFractionDigits="0"/></span> 
						  <c:if test="${specs.integCur_iType==1 }"><span integralType="1" id="integralType">商品积分 </span></c:if><c:if test="${specs.integCur_iType==2 }"><span integralType="2" id="integralType">健康积分</span> </c:if><c:if test="${specs.integCur_iType==3 }"><span integralType="3" id="integralType">教育积分 </span></c:if>						 
						  +  ¥<span id="jine2"><fmt:formatNumber type="number" value="${specs.integCur_c * payNum}" pattern="0.00" maxFractionDigits="2"/></span>
					</c:if> 
				
				</span>
			</div>
			<div class='tel'>
				<span class="fL tel_span">取货人电话:<input id="tel" type="tel" value="${user.phone }" readonly  class=" tel_input" /></span>
				<!-- <span class="tel_s">下单后会把订单提货码发送至此号</span> -->
				<span class="fL tel_span">当前提货店铺:<input  type="tel" id="thstore" value="" readonly  class=" tel_input" style="width: 55%"/></span>
			</div>
	 		<div class='telxs'>
				<span class="tel_xs" id="chooseStore">请选择提货店铺</span>
			</div>
			<div class='tel'>
				<span class="fL bz_span ">订单备注:</span>
				<input type="text" id="describe" placeholder="(选填) 其他要求" class="bz_input" />
			</div>

			<div class="subOrder white">

			
				<div class="fR sub_btn" onclick="doPaySubmit();">确认提交</div>
			
				<div class="fL sub_totale">
					<span>待支付&nbsp;&nbsp;¥</span>
					
		            <c:if test="${payType==1}">							  
					   <span id="dcartTotal"><fmt:formatNumber type="number" value="0.00" pattern="0.00" maxFractionDigits="2"/></span>							      
					</c:if>			        
					<c:if test="${payType==2}">							   
					       <span id="dcartTotal"><fmt:formatNumber type="number" value="${specs.currency * payNum}" pattern="0.00" maxFractionDigits="2"/></span>							      					   
					</c:if>
					<c:if test="${payType==3}">
					     <span id="dcartTotal"><fmt:formatNumber type="number" value="${specs.integCur_c * payNum }" pattern="0.00" maxFractionDigits="2"/></span>	   
				    </c:if>
				
				    
				</div>
			</div>
			<input type="hidden" id="orderNum" value=""/>
			<input type="hidden" id="storeValue" value="${storeid }"/>
		</div>
		 <div class="bot">
					<div class="stio">
			 			<!-- <span class="current">当前所在店铺</span> -->
			 			<span class="current">请选择店铺</span>
					</div>
					<div class="shop currentShop" attr="${stores.storeid }-${stores.title }">
							<span class="tit" id="storeid" style="display: none">${Stores.storeid }</span>
							<span class="tit">${stores.title }</span>
							<span class="nei">店铺地址：${stores.address }</span>
						<a href="tel:${Stores.tel }"><span class="dianhua" ><i></i></span></a>
					</div>
					<c:if test="${fn:length(storeList) > 0}">
						<!-- <div class="stios">
				 			<span >商家其他店铺</span>
						</div> -->
							<c:forEach var="store" items="${storeList}" varStatus="s">
									<div class="shop" attr="${store.storeid }-${store.title }">
										<span class="tit" id="storeid" style="display: none">${store.storeid }</span>
											<span class="tit">${store.title }</span>
											<span class="nei">店铺地址：${store.address }</span>
										<a href="tel:${store.tel }"><span class="dianhua" ><i></i></span></a>
									</div>
							</c:forEach>
					</c:if>
		</div>
	</body>
	<script type="text/javascript" src="${BASE_PATH}/static/app/js/jquery-3.1.1.min.js"></script>
	<!-- amazeui -->
	<script type="text/javascript" src="${BASE_PATH}/static/ui/js/amazeui.min.js"></script>
	<!-- lib -->
	<script type="text/javascript" src="${BASE_PATH}/static/lib/layer/layer.js"></script>
	<script type="text/javascript" src="${BASE_PATH}/static/lib/template/template.js"></script>
	<!-- app -->
	<script type="text/javascript" src="${BASE_PATH}/static/app/js/kit.js"></script>
	<script type="text/javascript" src="${BASE_PATH}/static/lib/template/template-ext.js"></script>
	<script type="text/javascript" src="${BASE_PATH}/static/lib/myAlert/module.js"></script>
	<script type="text/javascript">
	$(active);	     
	 var active="${active}";
     var storesTitle="${stores.title }"
	 var thstore=document.getElementById("thstore");
	/*  var current=document.getElementsByClassName("current")[0]; */
	 //判断是否是从店铺详情页进入产品详情页 进行的 立即兑换操作 是的话直接显示商铺
	function active(){
		   if(active=="2"){
			   console.log(active+"2active得");
/* 			   current.innerHTML="请选择店铺"; */
			   thstore.value=storesTitle;
		   }else if((active=="1")){
			   console.log(active+"1active得");
			   thstore.value="";
		   }	
     }
	
		$('.tel_input').focus();
		$('.tel_span').removeClass('ts');
		$("#chooseStore").click(function(){
			$(".bot").toggleClass("show");
			/* if(thstore==""||thstore==null){
				current.innerHTML="请选择店铺";
			}else{
				current.innerHTML="当前店铺";
			} */
		})
		$(".bot").on("click",".shop",function(){
			var attr = $(this).attr("attr");
		    var storeid = attr.split("-")[0];
		    var title = attr.split("-")[1];
			$("#xdstore").html(title);
			$("#thstore").val(title);
			$("#storeValue").val(storeid);
			$(".bot").removeClass("show");
		})
		var reg=/^[1-9]\d*$/ ;//匹配正整数
		var kucun="${goods.stock}";
		var buytypes="${goods.buytype}";
		var buycounts="${goods.buycount}";
		var xCounts="${goods.xCount}";
		var sppoints="${sppoint}";
		var jkpoints="${jkpoint}";
		var jypoints="${jypoint}";
		
		//减少数量
		function doReduce(){
			var numb=parseInt($("#num").val());
			var sppoint=parseFloat($("#sppoint").html());
			var jine=parseFloat($("#jine").html());
			if(numb>1){
				$("input[name=num]").val(numb-1);
				$("#dcartTotal").text(((numb-1)*jine).toFixed(2));
				$("#sppoint2").text(((numb-1)*sppoint).toFixed(0));
				$("#jine2").text(((numb-1)*jine).toFixed(2));
				$("#point1").text(((numb-1)*jine*jypoints).toFixed(0));
				$("#point2").text(((numb-1)*jine*jkpoints).toFixed(0));
				$("#point3").text(((numb-1)*jine*sppoints).toFixed(0));
			}else{
				$("input[name=num]").val(1);
				$("#dcartTotal").text((jine).toFixed(2));
				$("#sppoint2").text((sppoint).toFixed(0));
				$("#jine2").text((jine).toFixed(2));
				$("#point1").text((jine*jypoints).toFixed(0));
				$("#point2").text((jine*jkpoints).toFixed(0));
				$("#point3").text((jine*sppoints).toFixed(0));
			}
		}
		//增加数量
		function doAdd(){
			var buytype=parseInt(buytypes);
			var buycount=parseInt(buycounts);
			var xCount=parseInt(xCounts);
			var syCount=buycount-xCount;//剩余购买数
			var numb=parseInt($("#num").val());
			var sppoint=parseFloat($("#sppoint").html());
			var jine=parseFloat($("#jine").html());
			if(buytype==1){        
				if(numb<kucun){
					 $("input[name=num]").val(numb+1);
					 $("#dcartTotal").text(((numb+1)*jine).toFixed(2));
					 $("#sppoint2").text(((numb+1)*sppoint).toFixed(0));
					 $("#jine2").text(((numb+1)*jine).toFixed(2));
					 $("#point1").text(((numb+1)*jine*jypoints).toFixed(0));
					 $("#point2").text(((numb+1)*jine*jkpoints).toFixed(0));
					 $("#point3").text(((numb+1)*jine*sppoints).toFixed(0));
				}else{
					$("input[name=num]").val(kucun);
					$("#dcartTotal").text((kucun*jine).toFixed(2));
					$("#sppoint2").text((kucun*sppoint).toFixed(0));
				    $("#jine2").text((kucun*jine).toFixed(2));
				    $("#point1").text((kucun*jine*jypoints).toFixed(0));
					$("#point2").text((kucun*jine*jkpoints).toFixed(0));
					$("#point3").text((kucun*jine*sppoints).toFixed(0));
				}
			}else if(buytype==2){
				if(syCount>kucun){
					if(numb<kucun){
						 $("input[name=num]").val(numb+1);
						 $("#dcartTotal").text(((numb+1)*jine).toFixed(2));
						 $("#sppoint2").text(((numb+1)*sppoint).toFixed(0));
						 $("#jine2").text(((numb+1)*jine).toFixed(2));
						 $("#point1").text(((numb+1)*jine*jypoints).toFixed(0));
						 $("#point2").text(((numb+1)*jine*jkpoints).toFixed(0));
						 $("#point3").text(((numb+1)*jine*sppoints).toFixed(0));
					}else{
						$("input[name=num]").val(kucun);
						$("#dcartTotal").text((kucun*jine).toFixed(2));
						$("#sppoint2").text((kucun*sppoint).toFixed(0));
					    $("#jine2").text((kucun*jine).toFixed(2));
					    $("#point1").text((kucun*jine*jypoints).toFixed(0));
						$("#point2").text((kucun*jine*jkpoints).toFixed(0));
						$("#point3").text((kucun*jine*sppoints).toFixed(0));
					}
				}else{
					if(numb<syCount){
						 $("input[name=num]").val(numb+1);
						 $("#dcartTotal").text(((numb+1)*jine).toFixed(2));
						 $("#sppoint2").text(((numb+1)*sppoint).toFixed(0));
						 $("#jine2").text(((numb+1)*jine).toFixed(2));
						 $("#point1").text(((numb+1)*jine*jypoints).toFixed(0));
						 $("#point2").text(((numb+1)*jine*jkpoints).toFixed(0));
						 $("#point3").text(((numb+1)*jine*sppoints).toFixed(0));
					}else{
						if(xCount>0){
							Kit.ui.alert("每个用户限购"+buycount+"个,您还能购买"+syCount+"个！")
						}else{
							Kit.ui.alert("每个用户限购"+buycount+"个！")
						}
						$("input[name=num]").val(syCount);
						$("#dcartTotal").text((syCount*jine).toFixed(2));
						$("#sppoint2").text((syCount*sppoint).toFixed(0));
					    $("#jine2").text((syCount*jine).toFixed(2));
					    $("#point1").text((syCount*jine*jypoints).toFixed(0));
						$("#point2").text((syCount*jine*jkpoints).toFixed(0));
						$("#point3").text((syCount*jine*sppoints).toFixed(0));
					}
				}
			}
		}
		//输入数量
		function changenum(){
			var buytype=parseInt(buytypes);
			var buycount=parseInt(buycounts);
			var xCount=parseInt(xCounts);
			var syCount=buycount-xCount;//剩余购买数
			var numb=parseInt($("#num").val());
			var sppoint=parseFloat($("#sppoint").html());
			var jine=parseFloat($("#jine").html());
			if(reg.test(numb)){
				if(buytype==1){
					if(numb>kucun){
						$("input[name=num]").val(kucun);
						$("#dcartTotal").text((kucun*jine).toFixed(2));
						$("#sppoint2").text((kucun*sppoint).toFixed(0));
					    $("#jine2").text((kucun*jine).toFixed(2));
					    $("#point1").text((kucun*jine*jypoints).toFixed(0));
						$("#point2").text((kucun*jine*jkpoints).toFixed(0));
						$("#point3").text((kucun*jine*sppoints).toFixed(0));
					}else{
						$("input[name=num]").val(numb);
						 $("#dcartTotal").text((numb*jine).toFixed(2));
						 $("#sppoint2").text((numb*sppoint).toFixed(0));
						 $("#jine2").text((numb*jine).toFixed(2));
						 $("#point1").text((numb*jine*jypoints).toFixed(0));
						 $("#point2").text((numb*jine*jkpoints).toFixed(0));
						 $("#point3").text((numb*jine*sppoints).toFixed(0));
					}
				}else if (buytype==2){
					if(syCount>kucun){
						if(numb>kucun){
							$("input[name=num]").val(kucun);
							$("#dcartTotal").text((kucun*jine).toFixed(2));
							$("#sppoint2").text((kucun*sppoint).toFixed(0));
						    $("#jine2").text((kucun*jine).toFixed(2));
						    $("#point1").text((kucun*jine*jypoints).toFixed(0));
							$("#point2").text((kucun*jine*jkpoints).toFixed(0));
							$("#point3").text((kucun*jine*sppoints).toFixed(0));
						}else{
							$("input[name=num]").val(numb);
							 $("#dcartTotal").text((numb*jine).toFixed(2));
							 $("#sppoint2").text((numb*sppoint).toFixed(0));
							 $("#jine2").text((numb*jine).toFixed(2));
							 $("#point1").text((numb*jine*jypoints).toFixed(0));
							 $("#point2").text((numb*jine*jkpoints).toFixed(0));
							 $("#point3").text((numb*jine*sppoints).toFixed(0));
						}
					}else{
						if(numb>syCount){
							if(xCount>0){
								Kit.ui.alert("每个用户限购"+buycount+"个,您还能购买"+syCount+"个！")
							}else{
								Kit.ui.alert("每个用户限购"+buycount+"个！")
							}
							$("input[name=num]").val(syCount);
							$("#dcartTotal").text((syCount*jine).toFixed(2));
							$("#sppoint2").text((syCount*sppoint).toFixed(0));
						    $("#jine2").text((syCount*jine).toFixed(2));
						    $("#point1").text((syCount*jine*jypoints).toFixed(0));
							$("#point2").text((syCount*jine*jkpoints).toFixed(0));
							$("#point3").text((syCount*jine*sppoints).toFixed(0));
						}else{
							$("input[name=num]").val(numb);
							 $("#dcartTotal").text((numb*jine).toFixed(2));
							 $("#sppoint2").text((numb*sppoint).toFixed(0));
							 $("#jine2").text((numb*jine).toFixed(2));
							 $("#point1").text((numb*jine*jypoints).toFixed(0));
							 $("#point2").text((numb*jine*jkpoints).toFixed(0));
							 $("#point3").text((numb*jine*sppoints).toFixed(0));
						}
					}
				}
			}else{
				Kit.ui.alert("只能输入数字");
				$("input[name=num]").val(1);
				$("#dcartTotal").text((jine).toFixed(2));
				$("#sppoint2").text((sppoint).toFixed(0));
				$("#jine2").text((jine).toFixed(2));
				$("#point1").text((jine*jypoints).toFixed(0));
				$("#point2").text((jine*jkpoints).toFixed(0));
				$("#point3").text((jine*sppoints).toFixed(0));
			}
		}
		
		 
		//商品规格	
		var specTitle="${specs.specTitle}";	
		var marketPrice="${marketPrice}";
		//多种规格提交订单
		
		 function doPaySubmit(){
			var usppoint=parseFloat("${user.sppoint}");
			var ujkpoint=parseFloat("${user.jkpoint}");
			var ujypoint=parseFloat("${user.jypoint}");
			var payType="${payType}";
			var pointType="";
			if(document.getElementById("integralType")){
				var integralType=document.getElementById("integralType").getAttribute("integralType");
			}			
			 try {
				 pointType=document.querySelector("#sppoint+b").getAttribute("pointType");
			} catch (e) {
				// TODO: handle exception
				pointType="";
			}
			
			var type=${goods.type};
			var storeid=$("#storeValue").val();
			var kucun="${specs.stockNum}";
			
			var tel = $("#tel").val();
			var describe = $("#describe").val();
			var sppoint2=parseFloat($("#sppoint2").html());
			var jine2=parseFloat($("#jine2").html());
			var numb=$("#num").val();
			var params = {goodsid:"${goods.id}",goodsName:"${goods.name}",payType:payType,pointType:pointType,type:type,goodsThumb:"${goods.thumb}",numb:numb,tel:tel,storeid:storeid,describe:describe,amount:jine2,point:sppoint2,specTitle:specTitle,marketPrice:marketPrice};
			var reg = /^1[3|4|5|7|8|9]\d{9}$/;
			//判断是否已经选择店铺
		    if(thstore.value==""||thstore.value==null){
				myAlert.alert("请选择购买店铺 ");
				return;
			}
			if(Kit.validate.isBlank(tel)){
				myAlert.alert("请填写收货人电话");
				$('.tel_span').addClass('ts');
				$('.tel_input').focus();
				return;
			}else if(!reg.test(tel)){
				myAlert.alert("请输入正确的号码");
				return;
			}else if(numb>(kucun-0)){
				myAlert.alert("库存不足");				
				return;
			}else if((parseInt(integralType) ==1 && usppoint<sppoint2) || (parseInt(integralType) ==2 && ujkpoint<sppoint2) || (parseInt(integralType) ==3 && ujypoint<sppoint2)){
				myAlert.alert("您的积分不足");
				return;
			} else {
				$('#selectShop','.tel_span').removeClass('ts');
						$("#orderNum").val("submit");
					Kit.ajax.post("${BASE_PATH}/order/save",params,function(result){
						if(result.flag==0){
							var jifn=0;
							if(jine2>0){
								if("${payType}"=='3'){
									jifn="${specs.integCur_i * payNum}";
									Kit.render.redirect("${BASE_PATH}/order/prepay/"+result.object.orderNum+"?jifn="+jifn+"&payType=${payType}");
								}else{
									Kit.render.redirect("${BASE_PATH}/order/prepay/"+result.object.orderNum+"?jifn="+jifn+"&payType=${payType}");
								}
							}else{
								Kit.render.redirect("${BASE_PATH}/order/jfpay/"+result.object.orderNum);
							}
						}else{
							Kit.ui.alert(result.message);
						} 
					});
				}
			} 
		$(function(){
			var orderNum=$("#orderNum").val();
			if(orderNum =="submit"){
				window.history.go(-1);
			}
		})
		 function turnToOrderList(orderNum){
				Kit.render.redirect("${BASE_PATH}/order/detail/"+orderNum);
		}
	</script>
</html>